package com.wk.code.wkserver.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wk.code.wkserver.entity.OrderTakingRecord;
import com.wk.code.wkserver.entity.TechType;
import com.wk.code.wkserver.mapper.OrderTakingRecordMapper;
import com.wk.code.wkserver.mapper.TechTypeMapper;
import com.wk.code.wkserver.request.admin.TechTypeRequest;
import com.wk.code.wkserver.response.admin.TechTypeResponse;
import com.wk.code.wkserver.response.base.PageInfo;
import com.wk.code.wkserver.service.IOrderTakingRecordService;
import com.wk.code.wkserver.service.ITechTypeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 技术类别表 服务实现类
 * </p>
 *
 * @author wq
 * @since 2021-08-15
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class OrderTakingRecordServiceImpl extends ServiceImpl<OrderTakingRecordMapper, OrderTakingRecord> implements IOrderTakingRecordService {


    @Override
    public void save(Integer demandId, Integer techUserId) {
        OrderTakingRecord record = new OrderTakingRecord();
        record.setDemandId(demandId);
        record.setTechUserId(techUserId);
        save(record);
    }

    @Override
    public OrderTakingRecord selectOrderTakingRecord(Integer techUserId, Integer id) {
        return baseMapper.selectOne(new LambdaQueryWrapper<OrderTakingRecord>().eq(OrderTakingRecord::getTechUserId, techUserId).
                eq(OrderTakingRecord::getDemandId, id));
    }

    @Override
    public List<OrderTakingRecord> selectOrderTakingRecords(List<Integer> techUserIds) {
        return baseMapper.selectList(new LambdaQueryWrapper<OrderTakingRecord>().in(OrderTakingRecord::getTechUserId, techUserIds));
    }
}
